<?php
// +----------------------------------------------------------------------
// | Name 风音框架
// +----------------------------------------------------------------------
// | Author 唐启云 <tqy@fxri.net>
// +----------------------------------------------------------------------
// | Copyright Copyright © 2016-2099 方弦研究所. All rights reserved.
// +----------------------------------------------------------------------
// | Link https://www.fxri.net
// +----------------------------------------------------------------------
namespace fxapp\facade_ext;

use \fxapp\oracle\Base as BaseOracle;
use \fxapp\oracle\File as FileOracle;
use \fxapp\oracle\Rule as RuleOracle;
use \fxapp\oracle\User as UserOracle;

/**
 * 基础类
 */
class Base
{
    /**
     * 神谕
     * @param string $name 名称
     * @return BaseOracle|FileOracle|RuleOracle|UserOracle
     */
    public function oracle($name)
    {
        // 初始化变量
        static $models;
        $name = strtolower($name);
        $class = '\\fxapp\\oracle\\' . ucfirst($name);
        if (!isset($models[$name]) || is_null($models[$name])) {
            if (class_exists($class)) {
                $models[$name] = new $class();
            } else {
                $models[$name] = null;
            }
        }
        return $models[$name];
    }
}
